package com.gg.user.gguser.dao;

import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author yangxinlei
 * @date 2020/5/22
 */
@Mapper
@CacheNamespace
public interface GgHomeMapper {

    // 机构数量---->公司身份
    @Select("select count(*) from gg_user where gg_grade=3")
    Integer getHometopUserGrade();

    // 员工数量---->公司身份下绑定的   超管客服没有这个
    @Select("select count(*) from gg_binding where gg_b_d_user_id = '10'")
    Integer getHometopUserBinding();

    // 合同数量
    @Select("select count(*) from gg_contract")
    Integer getHomeTopContract();

    //公库数量
    @Select("select count(*) from gg_information")
    Integer getHomeTopInformation();

    // 商机数量
    @Select("select count(*) from gg_businessopportunity")
    Integer getHomeTopBusinessopportunity();

    //系统收录信息数量
    @Select("select count(*) from gg_company")
    Integer getHomeTopCompany();

    // 今日联系
    @Select("select gg_bo_name as ggBoName, gg_bo_id as ggBoId,date_format(gg_bo_update, '%Y-%m-%d') as ggBoUpdate from gg_businessopportunity where gg_bo_next_time>=#{dataString} ORDER BY gg_bo_update limit 10")
    List<Map<Object,Object>> contactToday(@Param("dataString")String dataString);

    //  近期到期合同
    @Select("select gg_c_institutional_name as ggCInstitutionalName,gg_c_id as ggCId,date_format(gg_c_due_time, '%Y-%m-%d') as ggCDueTime from gg_contract where gg_c_due_time>=#{dataString} ORDER BY gg_c_due_time limit 10")
    List<Map<Object,Object>> getGgContractDataobjectCount(@Param("dataString")String dataString);

    // 全部商机
    @Select("select count(*) from gg_businessopportunity")
    Integer businessopportunityCount();

    // 全部合同
    @Select("select count(*) from gg_contract")
    Integer contractCount();

    // 全部信息
    @Select("select count(*) from gg_information")
    Integer informationCount();
}
